<!--
 * @Author       : wfl
 * @LastEditors: ww
 * @description  :
 * @updateInfo   :
 * @Date         : 2022-11-23 16:18:57
 * @LastEditTime: 2023-06-30 17:41:00
-->
<script lang="ts" setup name="Concurrent">
import ActionType from '@main/views/approve-workflow/WorkFlow/ActionType.vue'

defineProps({
  config: {
    type: Object,
    default: () => {
      return {}
    }
  },
  level: {
    type: Number,
    default: 1
  },
  // 条件数
  size: {
    type: Number,
    default: 0
  }
})
const emit = defineEmits<{
  (event: 'selected'): void
  (event: 'leftMove'): void
  (event: 'copy'): void
  (event: 'delNode'): void
  (event: 'rightMove'): void
  (event: 'insertNode', val: any): void
}>()
</script>

<template>
  <div class="node">
    <div class="node-body" @click="emit('selected')">
      <div v-if="level > 1" class="node-body-left" @click.stop="emit('leftMove')">
        <i class="el-icon-arrow-left"></i>
      </div>
      <div class="node-body-main">
        <div class="node-body-main-header">
          <span class="title">
            <i class="el-icon-s-operation"></i>
            <ellipsis
              class="name"
              hover-tip
              :content="config.name ? config.name : `并行任务${level}`"
            />
          </span>
          <span class="option">
            <el-tooltip effect="dark" content="复制分支" placement="top">
              <i class="el-icon-copy-document" @click="emit('copy')"></i>
            </el-tooltip>
            <i class="ikflow ikflow-guanbi trans-all-25" @click.stop="emit('delNode')"></i>
          </span>
        </div>
        <div class="node-body-main-content">
          <span>并行任务（同时进行）</span>
        </div>
      </div>
      <div v-if="level < size" class="node-body-right" @click.stop="emit('rightMove')">
        <i class="el-icon-arrow-right"></i>
      </div>
    </div>
    <div class="node-footer">
      <div class="btn">
        <ActionType @insertNode="(type: string) => emit('insertNode', type)" />
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.node {
  padding: 30px 55px 0;
  width: var(--node-width);

  .node-body {
    overflow: hidden;
    cursor: pointer;
    min-height: 80px;
    max-height: 120px;
    position: relative;
    border-radius: 5px;
    background-color: var(--el-bg-color);
    box-shadow: var(--el-box-shadow-light);

    &:hover {
      .node-body-left,
      .node-body-right {
        i {
          display: block !important;
        }
      }

      .node-body-main {
        .option {
          display: inline-block !important;
        }
      }

      box-shadow: 0 0 3px 0 var(--theme-primary);
    }

    .node-body-left,
    .node-body-right {
      display: flex;
      align-items: center;
      position: absolute;
      height: 100%;

      i {
        display: none;
      }

      &:hover {
        background-color: #ececec;
      }
    }

    .node-body-left {
      left: 0;
    }

    .node-body-right {
      right: 0;
    }

    .node-body-main {
      position: absolute;
      width: 188px;
      left: 17px;
      display: inline-block;

      .node-body-main-header {
        padding: 10px 0 5px;
        font-size: xx-small;
        position: relative;

        .title {
          color: #718dff;

          .name {
            display: inline-block;
            height: 14px;
            width: 130px;
            margin-left: 2px;
          }
        }

        .option {
          position: absolute;
          right: 0;
          display: none;
          font-size: medium;

          i {
            color: #888;
            padding: 0 3px;
          }
        }
      }

      .node-body-main-content {
        padding: 6px;
        color: var(--el-text-color-regular);
        font-size: 14px;

        i {
          position: absolute;
          top: 55%;
          right: 10px;
          font-size: medium;
        }
      }
    }
  }

  .node-footer {
    position: relative;

    .btn {
      width: 100%;
      display: flex;
      height: 70px;
      padding: 32px 0;
      justify-content: center;
    }

    :deep(.el-button) {
      height: 32px;
      width: 32px;
    }

    &::before {
      content: "";
      position: absolute;
      inset: 0;
      z-index: -1;
      margin: auto;
      width: 2px;
      height: 100%;
      background-color: var(--el-text-color-disabled);
    }
  }
}
</style>
